<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
//			localStorage.setItem("key","admin");
//			sessionStorage.setItem("seson","sessIontest");
			
//			alert(sessionStorage.getItem("key"));
			window.onload=function(){
				
				var arrs=[];
				if(localStorage.getItem("list")){
					arrs=localStorage.getItem("list").split(",");
					for(var i=0;i<arrs.length;i++){
						addList(arrs[i]);
					}
				}
				
				document.getElementById("btn").addEventListener("click",function(){
					var name =document.getElementById("name");
					addList(name.value);
					arrs.push(name.value);
					localStorage.setItem("list",arrs)
					
				});
			}
			function addList(name){
				var ul = document.getElementById("item");
				var newli = document.createElement("li");
				newli.innerHTML=name;
				ul.append(newli);
			}
			
		</script>
	</head>
	<body>
		<input type="text" id="name" />
		<input type="button" id="btn" value="添加"/>
		<ul id="item">
			
		</ul>
	</body>
</html>
